<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <jsp:include page="/resources/inc/pageHead.jsp" />
</head>
<body>
<form class="layui-form layui-form-pane" id="_form">
    <c:forEach items="${interviewRecordsList}" var="interviewRecords" varStatus="status">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>第${status.index + 1}次面试</legend>
            <div class="layui-field-box">
                <table class="layui-table">
                    <colgroup>
                        <col width="100">
                        <col width="400">
                    </colgroup>
                    <tbody align="center">
                    <tr>
                        <td>面试官</td>
                        <td>${interviewRecords.interviewer}</td>
                    </tr>
                    <tr>
                        <td>面试时间</td>
                        <td><fmt:formatDate value='${interviewRecords.ctime}' pattern='yyyy-MM-dd HH:mm:ss'/></td>
                    </tr>
                    <tr>
                        <td>面试内容</td>
                        <td>${interviewRecords.content}</td>
                    </tr>
                    <tr>
                        <td>面试意见</td>
                        <td>${interviewRecords.interviewOption}</td>
                    </tr>
                    </tbody>
                </table>
                <button type="button" onclick="doEdit(${interviewRecords.id})" class="layui-btn">编辑</button>
                <button type="button" onclick="doDelete(${interviewRecords.id},this)"
                        class="layui-btn layui-btn-danger">删除
                </button>
            </div>
        </fieldset>
    </c:forEach>
    <c:if test="${interviewRecordsList.size() < 1}">
        <table class="layui-table">
            <tr>
                <td colspan="2">无面试记录</td>
            </tr>
        </table>

    </c:if>
</form>
<jsp:include page="/resources/inc/footer.jsp" />
<script>
    var index = parent.layer.getFrameIndex(window.name);
    function doEdit(id) {
        parent.layer.close(index);
        parent.Common.openPage({
            title: "编辑面试记录",
            url: "${basePath}/oa/hr/resume/updateInterviewRecords",
            param: Common.getParam({id: id})
        });
    }
    function doDelete(id, button) {
        layer.confirm('确定删除么？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.ajax({
                type: "GET",
                url: "${basePath}/oa/hr/resume/deleteInterviewRecords?id=" + id,
                success: function (res) {
                    if (res.code != 1) {
                        if (typeof(res.data) != "undefined" && res.data.length > 0) {
                            layer.msg(res.data, {icon: 5});
                        } else {
                            layer.msg(res.message, {icon: 5});
                        }
                    } else {
                        layer.msg('删除成功！', {icon: 1});
                        $(button).parents(".layui-field-title").remove();
                        var tableLength = $("#_form").find(".layui-field-title").length;
                        if (tableLength < 1) {
                            $("#_form").append('  <table class="layui-table"> <tr> <td colspan="2">无面试记录</td> </tr> </table>')
                        }
                    }
                },
                error: function (res) {
                    layer.msg('删除失败！', {icon: 5});
                }
            });
        }, function () {
        });

    }
</script>
</body>
</html>
